

chrome.runtime.onMessage.addListener(async (msg, sender) => {
    location.reload();
})


$(document).ready(function() {
    doSpamPage();
});


var doing = false;
function doSpamPage(){
    var pageTitle = $("title").text();
    console.log("pageTitle:"+pageTitle);
    if(pageTitle=='Just a moment...' || pageTitle=='请稍候…'){

            console.log("sleep and reload");
            setTimeout(() => {
                 location.reload();
            }, 15000);
    }else{
        setTimeout(() => {
                 setOk();
            }, 15000);

    }
}

function setOk(){
    var type = "ozon_spm_ok";
    chrome.runtime.sendMessage({ data: {type}, close: false});
}